import request from '@/utils/request'

export default {
  getTBLinkList(searchModel) {
    return request({
      url: '/tb/linkList',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        tbLink: searchModel.tbLink,
        name: searchModel.name,
        upTime: searchModel.upTime,
        storeId: searchModel.storeId
      }
    })
  },
  saveTbLink(tbLink) {
    if (tbLink.id === null) {
      return this.addTbLink(tbLink)
    }
    return this.updateTbLink(tbLink)
  },
  addTbLink(tbLinkList) {
    return request({
      url: '/tb/addLink',
      method: 'post',
      data: tbLinkList
    })
  },
  updateTbLink(tbLink) {
    return request({
      url: '/tb',
      method: 'put',
      data: tbLink
    })
  },
  deleteTbLinkById(id) {
    return request({
      url: `/tb/${id}`,
      method: 'delete'
    })
  },
  getCsvNum() {
    return request({
      url: '/tb/csvNum',
      method: 'get'
    })
  },
  judgeUpload(judgeModel) {
    return request({
      url: '/tb/judgeUpload',
      method: 'get',
      params: {
        judgeTbLink: judgeModel.judgeTbLink
      }
    })
  },
  getChangeLink(searchModel) {
    return request({
      url: '/tb/changeLink',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        tbLink: searchModel.tbLink,
        name: searchModel.name,
        upTime: searchModel.upTime,
        storeId: searchModel.storeId
      }
    })
  },
  getEleInfo(searchModel) {
    return request({
      url: '/tb/eleInfo',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        name: searchModel.name,
        upTime: searchModel.upTime
      }
    })
  },
  getTbLinkById(id) {
    return request({
      url: `/tb/${id}`,
      method: 'get'
    })
  },
  exchangeCardNum(value) {
    return request({
      url: '/tb/exchangeCardNum',
      method: 'get',
      params: {
        cardInfo: value
      }
    })
  },
  getTBTitleList(searchModel) {
    return request({
      url: '/tb/titleInfo',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize
      }
    })
  },
  getThList(searchModel) {
    return request({
      url: '/tb/getThList',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        chapterName: searchModel.chapterName
      }
    })
  },
  addTbTh(tbTh) {
    return request({
      url: '/tb/addTbTh',
      method: 'post',
      data: tbTh
    })
  },
  tbUnLock() {
    return request({
      url: '/tb/tbUnLock',
      method: 'post'
    })
  },
  getPurchaseList() {
    return request({
      url: '/tb/purchaseInfo',
      method: 'get'
    })
  },
  purchase(purchaseInfo) {
    return request({
      url: '/tb/purchase',
      method: 'get',
      params: {
        type: purchaseInfo.type,
        price: purchaseInfo.price,
        inventory: purchaseInfo.inventory
      }
    })
  },
  getOrderList(searchModel) {
    return request({
      url: '/tb/orderList',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize
      }
    })
  }
}
